<%@ page pageEncoding="UTF-8"%>

<%@ taglib uri="/tags/struts-tiles" prefix="tiles"%>
<%@ taglib uri="/tags/struts-html" prefix="html"%>
<%@ taglib uri="/tags/struts-logic" prefix="logic"%>
<%@ taglib uri="/tags/struts-nested" prefix="nested"%>
<%@ taglib uri="/tags/struts-bean" prefix="bean"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>

<div>
	<c:choose>
		<c:when test="${search_vo.trainStationFrom eq '' && search_vo.trainStationFrom eq ''}">
			<p align="center" style="margin: 20px 0;">请在查询框内输入出发站与到达站信息...</p>
		</c:when>
		<c:otherwise>
			<p class="nav_result">
				<logic:present name="result.page">
					由<label class="redb" style="margin:0 5px;">${search_vo.trainStationFrom}</label>到<label class="redb" style="margin:0 5px;">${search_vo.trainStationTo}</label>的车次如下：
				</logic:present>
				<logic:notPresent name="result.page">
					由<label class="redb" style="margin:0 5px;">${search_vo.trainStationFrom}</label>到<label class="redb" style="margin:0 5px;">${search_vo.trainStationTo}</label>的车次没有找到：
				</logic:notPresent>
			</p>
			<table width="100%" cellpadding="0" cellspacing="0" border="1" style="text-align:center;"  class="datagrid">
				<thead>
					<tr> 
						<td>车次</td>
						<td>类型</td>
						<td>出发站</td>
						<td>开车时间</td>
						<td>到达站</td>
						<td>到达时间</td>
						<td>用时</td>
						<td>里程</td>
						<td>硬座</td>
						<td>软座</td>
						<td>硬卧上/中/下</td>
						<td>软卧上/下</td>
						<td>二等/一等/特等软座</td>
						<td class="side"></td>
					</tr>
				</thead>
				<tbody>
					<logic:present name="result.page">
						<logic:iterate name="result.page" property="items" id="entity" indexId="idx">
							<tr <c:if test="${idx % 2 == 1}">bgcolor="#fafbf5"</c:if>>
								<td><a style="text-decoration: underline;" href="app/train/search?code=${entity.trainNumberEncode}">${entity.trainNumber}</a></td>
								<td>${entity.trainType}</td>
								<td><a style="text-decoration: underline;" href="app/train/search?station=${entity.trainScheduleStartingVO.trainStationName}">${entity.trainScheduleStartingVO.trainStationName}</a></td>
								<td>${entity.trainScheduleStartingVO.trainDepartureTime}</td>
								<td><a style="text-decoration: underline;" href="app/train/search?station=${entity.trainScheduleTerminationVO.trainStationName}">${entity.trainScheduleTerminationVO.trainStationName}</a></td>
								<td>${entity.trainScheduleTerminationVO.trainArriveTime}</td>
								<td>${entity.trainScheduleSubRuntimeVO}</td>
								<td>${entity.trainScheduleTerminationVO.trainRange - entity.trainScheduleStartingVO.trainRange}公里</td>
								<td>${entity.trainScheduleTerminationVO.trainPriceHardSeat - entity.trainScheduleStartingVO.trainPriceHardSeat}</td>
								<td>${entity.trainScheduleTerminationVO.trainPriceSoftSeat - entity.trainScheduleStartingVO.trainPriceSoftSeat}</td>
								<td>${entity.trainScheduleTerminationVO.trainPriceHardBerthTop - entity.trainScheduleStartingVO.trainPriceHardBerthTop}/${entity.trainScheduleTerminationVO.trainPriceHardBerthMiddle - entity.trainScheduleStartingVO.trainPriceHardBerthMiddle}/${entity.trainScheduleTerminationVO.trainPriceHardBerthLow - entity.trainScheduleStartingVO.trainPriceHardBerthLow}</td>
								<td>${entity.trainScheduleTerminationVO.trainPriceSoftBerthTop - entity.trainScheduleStartingVO.trainPriceSoftBerthTop}/${entity.trainScheduleTerminationVO.trainPriceSoftBerthLow - entity.trainScheduleStartingVO.trainPriceSoftBerthLow}</td>
								<td>${entity.trainScheduleTerminationVO.trainPriceSoftLv2nd - entity.trainScheduleStartingVO.trainPriceSoftLv2nd}/${entity.trainScheduleTerminationVO.trainPriceSoftLv1st - entity.trainScheduleStartingVO.trainPriceSoftLv1st}/${entity.trainScheduleTerminationVO.trainPriceSoftLvBest - entity.trainScheduleStartingVO.trainPriceSoftLvBest}</td>
								
								<td class="side"><c:if test="${idx > -1}">
								<form name="myform" id="myform" action="app/order_build" method="post">
								<input type="hidden" name="from" value="${entity.trainStationStarting}"/>
								<input type="hidden" name="to" value="${entity.trainScheduleTerminationVO.trainStationName}"/>
								<input type="hidden" name="code" value="${entity.trainNumber}"/>
								<input  style="font-color:blue;" onclick="if(${sessionScope.USER==null}) alert('请先登录！');else{submit();}" type="button" value="买票" />
								</c:if></form></td>
									</tr>
						</logic:iterate>
					</logic:present>
					<logic:notPresent name="result.page">
						<tr><td colspan="13">很抱歉，您查询的车站其中一个暂时没有(可能停运).</td></tr>
					</logic:notPresent>
				<tbody>
				<logic:present name="result.page">
					<tfoot>
						<tr>
							<td colspan="13">
								<logic:notEmpty name="result.page">
									<bean:define id='total' name="result.page" property="totalPage" />
									<bean:define id='currentPage' name="result.page" property="currentPage" />
									<div class="pagination">
										<div class="pageopr">
											<a href="javascript:switch_page(1);" title="首页" class="loca_btn">首页</a>
											<a href="javascript:switch_page(<c:out value='${currentPage - 1 eq 0 ? 1 : currentPage - 1}' />);" title="上一页" class="loca_pre">上一页</a>
											<a href="javascript:switch_page(<c:out value='${currentPage + 1 gt total ? total : currentPage + 1}' />);" title="下一页" class="loca_next">下一页</a>
											<a href="javascript:switch_page(<bean:write name='result.page' property='totalPage' />);" title="尾页" class="loca_btn">尾页</a>
										</div>
										<div class="lstinfo">
											<span>数据：<logic:present name="result.page"><bean:write name="result.page" property="totalCount" /></logic:present><logic:notPresent name="result.page">0</logic:notPresent>条</span>
											<span>第<input type="text" class="pageinput text" id="rdpage" value="<bean:write name='result.page' property='currentPage' />" size="5" />/<label id='totalPage'><logic:present name="result.page"><bean:write name="result.page" property="totalPage" /></logic:present><logic:notPresent name="result.page">1</logic:notPresent></label>页</span>
											<span><a href="javascript:switch_page();" title="转到" class="loca_btn">转到</a></span>
										</div>
									</div>
									<b class="clear"></b>
								</logic:notEmpty>
							</td>
						</tr>
					</tfoot>
				</logic:present>
			</table>
		</c:otherwise>
	</c:choose>
</div>